<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <script>
      // 1、js一共有多少种数据类型?
      // 10种：
      // 基本：number、string、bigint、Boolean、undefined、null、symbol

      // 引用：function、object、array

      // 2、js检测数据类型有哪些方法?
      // typeof、 instanceof 、constructor、Object.prototype.toString.call()

      // 3、undefined和null的区别?	用typeof检测它们分别返回什么值?
      // undefined: 未定义，未赋值  typeof返回undefined
      // null： 空值、空引用        typeof返回object


      // 4、写出下列对应结果
      let str_4 = '0';
      let str1_4 = '';
      let str2_4 = ' ';
      let unde_4 = undefined;
      let nu_4 = null;
      let num_4 = 0;
      let num1_4 = -10;

      Boolean(str_4);  //true
      Boolean(str1_4);  //false
      Boolean(str2_4);  //true
      Boolean(unde_4);  //false
      Boolean(nu_4);  //false
      Boolean(num_4);  //false
      Boolean(num1_4);  //true

      // 5、写出下列对应结果	注意：需要分别使用Number、String、toString去转换数据类型
      let str_5 = '0'; // 0 0 [object Undefined]
      let num_5 = -10; // -10 -10 [object Undefined]
      let flag_5 = true; // 1 true [object Undefined]
      let ud_5 = undefined; // NaN undefined [object Undefined]
      let nu_5 = null; // 0 null [object Undefined]

      console.log(Number(nu_5));
      console.log(String(nu_5));
      console.log(toString(nu_5));

      // 6、检测下面的变量各自的数据类型
      let str_6 = '';  //string
      let num_6 = '-10';  //number
      let num1_6 = 0; //number
      let nu_6 = undefined;  //undefined
      let nu1_6 = 'undefined';  //string
      let nu2_6 = 'null';  //string
      let nu3_6 = null
      let obj1_6 = {};  //object
      let sy_6 = Symbol('n');  //symbol;  //object
      let obj_6 = '{}';  //string

      console.log(typeof str_6);  //string
    </script>
  </body>
</html>
